<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>工资</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<input type="hidden" name="empid" th:value="${session.loginUser.getEmpId()}">
<table id="table-user" class="layui-table" lay-filter="table-user"></table>
<script type="text/html" id="currentTableBar">
    <a shiro:hasPermission="zhuanzheng:button" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="jeu" th:if="${session.loginUser.getEmpId()==1}" >审核</a>
</script>
<script type="text/html" id="toolbar">
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width:110px">员工姓名</label>
                <div class="layui-input-inline">
                    <select th:if="${putong!='' and putong!=null}"  name="empId" class="layui-input"  >
                        <option th:each="a:${yuangong}" th:value="${a.id}" th:text="${a.empName}"></option>
                    </select>
                    <select th:if="${jingli!='' and jingli!=null}" name="empId" class="layui-input"  >
                        <option value="-1">全部员工</option>
                        <option th:each="a:${yuangong}" th:value="${a.id}" th:text="${a.empName}"></option>
                    </select>
                    <select th:if="${guanli!='' and guanli!=null}" name="empId" class="layui-input"  >
                        <option value="-1">全部员工</option>
                        <option th:each="a:${yuangong}" th:value="${a.id}" th:text="${a.empName}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button type="button" lay-submit class="layui-btn layui-btn-primary" lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
            </div>
        </div>
    </form>
    <div class="layui-btn-container">
        <button th:if="${jingli!='' and jingli!=null}" class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-filter="data-search-btn" lay-event="add"> 添加 </button>
        <button th:if="${guanli!='' and guanli!=null}" class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-filter="data-search-btn" lay-event="add"> 添加 </button>
    </div>
</script>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script th:inline="none">
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        let id=$(":input[name='empid']").val();
        table.render({
            elem: '#table-user',
            url: '/positive/list?id='+id,
            method:'post',
            page: true,
            limits: [1,5,10,15],
            limit: 10,
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'filedDate', title: '申请日期', sort: true},
                {field: 'employeeInfo', title: '申请人',templet:function (d){return d.employeeInfo.empName}},
                {field: 'filedText',title: '申请内容'},
                {field: 'vettingDate', title: '审批日期', sort: true},
                {field: 'vettingName', title: '管理员'},
                {field: 'stateOut', title: '审批结果',templet:function (d){return d.stateOut.stateName}},
                {field: 'vettingOp',title: '审批意见', sort: true},
                {field: 'stateOne', title: '状态',templet:function (d){return d.stateOne.stateName}},
                {field: 'posiDate',title: '创建时间', sort: true},
                {title: '操作', toolbar: '#currentTableBar', align: "center",width:150}
            ]],
            toolbar:"#toolbar",
        });

        /*添加计划*/
        table.on('toolbar(table-user)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                let id=$(":input[name='empid']").val();
                var index = layer.open({
                    title: '转正申请',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '/positive/insert?id='+id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            }
        });
        table.on('tool(table-user)', function (obj) {
            if (obj.event === 'jeu') {
                let sid = obj.data.stateOne.id;
                if (sid == 13) {
                    alert("该用户已通过,请选择其他的");
                    return false;
                }
                let id = obj.data.id;
                var index = layer.open({
                    title: '转正审批',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '/positive/edit?pid=' + id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            }
        })
        form.on('submit(data-search-btn)',function(data){
            var result=JSON.stringify(data.field);
            console.log(result);
            //执行搜索重载
            table.reload('table-user',{
                page:{
                    curr:1
                },
                where:{
                    empId:data.field.empId,
                }
            },'data');
            //阻止表单提交
            return false;
        })
    });
</script>
</body>
</html>